package com.woniu.controller;


import com.woniu.model.Result;
import com.woniu.service.elasticSearch.ElasticsearchForTest;
import com.woniu.service.vo.ShowTestVo;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author D
 * @since 2023-03-27 08:24:57
 */
@RestController
@RequestMapping("/testOutside")
public class TestOutsideController {
    @Resource
    ElasticsearchForTest elasticsearchForTest;

    /**
     * 搜索靶场数据
     *
     * @param condition 搜索条件，包含搜索关键字、分页信息等
     * @return 返回搜索结果，包含分页信息和靶场列表
     */
    @RequestMapping("/search")
    public Result<Page<ShowTestVo>> search(@RequestBody Map<String, Object> condition) {
        System.out.println(condition);
        System.out.println("-------------------------------");
        Page<ShowTestVo> showTestVoPage = elasticsearchForTest.searchByCondition(condition);
        System.out.println(showTestVoPage.getContent());
        return Result.successResult(showTestVoPage);
    }


}